package com.example.librarymanagement.vo;

import com.example.librarymanagement.entity.Role;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * @author ZHB
 */

@Data
@Accessors(chain = true)
public class UserVo {

    @ApiParam(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "联系电话")
    private String phone;

    @ApiModelProperty(value = "创建时间")
    private String created;

    @ApiModelProperty(value = "更新时间")
    private String updated;

    @ApiModelProperty(value = "最后登录时间")
    private String lastLogin;

    @ApiModelProperty(value = "状态")
    private Integer state;

    @ApiModelProperty(value = "角色列表")
    private List<Role> roles;

    public void setCreated(LocalDateTime created) {
        this.created = created.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public void setUpdated(LocalDateTime updated) {
        this.updated = updated.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public void setLastLogin(LocalDateTime lastLogin) {
        this.lastLogin = lastLogin.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
}
